﻿using System;
using System.Security.Cryptography;
using System.Text;
using System.Threading;
using HslCommunication.BasicFramework;
using HslCommunication.Enthernet;

namespace HslCommunication
{
	/// <summary>
	/// 系统的基本授权类
	/// </summary>
	// Token: 0x0200000D RID: 13
	public class Authorization
	{
		// Token: 0x06000066 RID: 102 RVA: 0x00003B04 File Offset: 0x00001D04
		static Authorization()
		{
			Authorization.niahdiahduasdbubfas = Authorization.iashdagsdawbdawda();
			bool flag = Authorization.naihsdadaasdasdiwasdaid != 0L;
			if (flag)
			{
				Authorization.naihsdadaasdasdiwasdaid = 0L;
			}
			bool flag2 = Authorization.nuasgdawydaishdgas != 24.0;
			if (flag2)
			{
				Authorization.nuasgdawydaishdgas = 24.0;
			}
			bool flag3 = Authorization.nuasgdaaydbishdgas != 0;
			if (flag3)
			{
				Authorization.nuasgdaaydbishdgas = 0;
			}
			bool flag4 = Authorization.nuasgdawydbishdgas != 24;
			if (flag4)
			{
				Authorization.nuasgdawydbishdgas = 24;
			}
		}

		// Token: 0x06000067 RID: 103 RVA: 0x00003BFC File Offset: 0x00001DFC
		private static void asidhiahfaoaksdnasoif(object obj)
		{
			for (int i = 0; i < 3600; i++)
			{
				Thread.Sleep(1000);
				bool flag = Authorization.naihsdadaasdasdiwasdaid == (long)Authorization.niasdhasdguawdwdad && Authorization.nuasgdaaydbishdgas > 0;
				if (flag)
				{
					return;
				}
			}
			NetSimplifyClient netSimplifyClient = new NetSimplifyClient("118.24.36.220", 18467);
			netSimplifyClient.ReadCustomerFromServer(500, SoftBasic.FrameworkVersion.ToString());
		}

		// Token: 0x06000068 RID: 104 RVA: 0x00003C78 File Offset: 0x00001E78
		internal static bool nzugaydgwadawdibbas()
		{
			Authorization.moashdawidaisaosdas += 1L;
			bool flag = Authorization.naihsdadaasdasdiwasdaid == (long)Authorization.niasdhasdguawdwdad && Authorization.nuasgdaaydbishdgas > 0;
			bool result;
			if (flag)
			{
				result = Authorization.nuasduagsdwydbasudasd();
			}
			else
			{
				bool flag2 = (Authorization.iashdagsdawbdawda() - Authorization.niahdiahduasdbubfas).TotalHours < Authorization.nuasgdawydaishdgas;
				if (flag2)
				{
					result = Authorization.nuasduagsdwydbasudasd();
				}
				else
				{
					result = Authorization.asdhuasdgawydaduasdgu();
				}
			}
			return result;
		}

		/// <summary>
		/// 商业授权则返回true，否则返回false
		/// </summary>
		/// <returns>是否成功进行商业授权</returns>
		// Token: 0x06000069 RID: 105 RVA: 0x00003CEC File Offset: 0x00001EEC
		internal static bool asdniasnfaksndiqwhawfskhfaiw()
		{
			bool flag = Authorization.naihsdadaasdasdiwasdaid == (long)Authorization.niasdhasdguawdwdad && Authorization.nuasgdaaydbishdgas > 0;
			bool result;
			if (flag)
			{
				result = Authorization.nuasduagsdwydbasudasd();
			}
			else
			{
				bool flag2 = (Authorization.iashdagsdawbdawda() - Authorization.niahdiahduasdbubfas).TotalHours < (double)Authorization.nuasgdawydbishdgas;
				if (flag2)
				{
					result = Authorization.nuasduagsdwydbasudasd();
				}
				else
				{
					result = Authorization.asdhuasdgawydaduasdgu();
				}
			}
			return result;
		}

		// Token: 0x0600006A RID: 106 RVA: 0x00003D54 File Offset: 0x00001F54
		internal static bool nuasduagsdwydbasudasd()
		{
			return true;
		}

		// Token: 0x0600006B RID: 107 RVA: 0x00003D68 File Offset: 0x00001F68
		internal static bool asdhuasdgawydaduasdgu()
		{
			return false;
		}

		// Token: 0x0600006C RID: 108 RVA: 0x00003D7C File Offset: 0x00001F7C
		internal static bool ashdadgawdaihdadsidas()
		{
			return Authorization.niasdhasdguawdwdad == 12345;
		}

		// Token: 0x0600006D RID: 109 RVA: 0x00003D9C File Offset: 0x00001F9C
		internal static DateTime iashdagsdawbdawda()
		{
			return DateTime.Now;
		}

		// Token: 0x0600006E RID: 110 RVA: 0x00003DB4 File Offset: 0x00001FB4
		internal static DateTime iashdagsaawbdawda()
		{
			return DateTime.Now.AddDays(1.0);
		}

		// Token: 0x0600006F RID: 111 RVA: 0x00003DDC File Offset: 0x00001FDC
		internal static DateTime iashdagsaawadawda()
		{
			return DateTime.Now.AddDays(2.0);
		}

		// Token: 0x06000070 RID: 112 RVA: 0x00003E04 File Offset: 0x00002004
		internal static void oasjodaiwfsodopsdjpasjpf()
		{
			Interlocked.Increment(ref Authorization.iahsduiwikaskfhishfdi);
		}

		// Token: 0x06000071 RID: 113 RVA: 0x00003E14 File Offset: 0x00002014
		internal static string nasduabwduadawdb(string miawdiawduasdhasd)
		{
			StringBuilder stringBuilder = new StringBuilder();
			MD5 md = MD5.Create();
			byte[] array = md.ComputeHash(Encoding.Unicode.GetBytes(miawdiawduasdhasd));
			md.Clear();
			for (int i = 0; i < array.Length; i++)
			{
				stringBuilder.Append(((int)(byte.MaxValue - array[i])).ToString("X2"));
			}
			return stringBuilder.ToString();
		}

		/// <summary>
		/// 设置本组件系统的授权信息，如果激活失败，只能使用24小时，24小时后所有的网络通信不会成功<br />
		/// Set the authorization information of this component system. If the activation fails, it can only be used for 8 hours. All network communication will not succeed after 8 hours
		/// </summary>
		/// <param name="code">授权码</param>
		// Token: 0x06000072 RID: 114 RVA: 0x00003E88 File Offset: 0x00002088
		public static bool SetAuthorizationCode(string code)
		{
			bool flag = Authorization.nasduabwduadawdb(code) == "91ACD60C551A2F0AE33F36D297BFB5E3";
			bool result;
			if (flag)
			{
				Authorization.nuasgdaaydbishdgas = 1;
				Authorization.nuasgdawydbishcgas = 286512937.0;
				Authorization.nuasgdawydaishdgas = 87600.0;
				result = Authorization.nuasduagsdwydbasudasd();
			}
			else
			{
				bool flag2 = Authorization.nasduabwduadawdb(code) == "B7D40F4D8B229E02AC463A096BCD5707";
				if (flag2)
				{
					Authorization.nuasgdaaydbishdgas = 1;
					Authorization.nuasgdawydbishcgas = 286512937.0;
					Authorization.nuasgdawydaishdgas = 2160.0;
					result = Authorization.nuasduagsdwydbasudasd();
				}
				else
				{
					bool flag3 = Authorization.nasduabwduadawdb(code) == "2765FFFDDE2A8465A9522442F5A15593";
					if (flag3)
					{
						Authorization.nuasgdaaydbishdgas = 10000;
						Authorization.nuasgdawydbishcgas = (double)Authorization.nuasgdawydbishdgas;
						Authorization.naihsdadaasdasdiwasdaid = (long)Authorization.niasdhasdguawdwdad;
						result = Authorization.nuasduagsdwydbasudasd();
					}
					else
					{
						result = Authorization.asdhuasdgawydaduasdgu();
					}
				}
			}
			return result;
		}

		// Token: 0x0400003A RID: 58
		private static readonly string Declaration = "禁止对本组件进行反编译，篡改源代码，如果用于商业用途，将追究法律责任，如需注册码，请联系作者，QQ号：200962190，邮箱：hsl200909@163.com，欢迎企业合作。";

		// Token: 0x0400003B RID: 59
		private static DateTime niahdiahduasdbubfas = DateTime.Now;

		// Token: 0x0400003C RID: 60
		internal static long naihsdadaasdasdiwasdaid = 0L;

		// Token: 0x0400003D RID: 61
		internal static long moashdawidaisaosdas = 0L;

		// Token: 0x0400003E RID: 62
		internal static double nuasgdawydbishcgas = 8.0;

		// Token: 0x0400003F RID: 63
		internal static int nuasgdaaydbishdgas = 0;

		// Token: 0x04000040 RID: 64
		internal static int nuasgdawydbishdgas = 8;

		// Token: 0x04000041 RID: 65
		internal static double nuasgdawydaishdgas = 24.0;

		// Token: 0x04000042 RID: 66
		internal static int nasidhadguawdbasd = 1000;

		// Token: 0x04000043 RID: 67
		internal static int niasdhasdguawdwdad = 12345;

		// Token: 0x04000044 RID: 68
		internal static int hidahwdauushduasdhu = 23456;

		// Token: 0x04000045 RID: 69
		internal static long iahsduiwikaskfhishfdi = 0L;

		// Token: 0x04000046 RID: 70
		internal static int zxnkasdhiashifshfsofh = 0;
	}
}
